package park.manage;

import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet;
import java.util.TreeSet;

public class WriteFile {
    public static void writeFile(HashSet<User> userHashSet) throws IOException {
        //每次写文件之前都先清空文件
        FileWriter fw =new FileWriter("src/park/manage/User.txt",false);
        for(User user:userHashSet){
            fw.write(user.toString()+"\n");
        }
        fw.flush();
        //释放资源
        fw.close();
    }
    public static void writeFile(HashSet<Manager> userHashSet,String path) throws IOException {
        //每次写文件之前都先清空文件
        FileWriter fw =new FileWriter(path,false);
        for(Manager manager:userHashSet){
            fw.write(manager.toString()+"\n");
        }
        fw.flush();
        //释放资源
        fw.close();
    }
    public static void writeFile(TreeSet<Car> carSet) throws IOException {
        //每次写文件之前都先清空文件
        FileWriter fw =new FileWriter("src/park/manage/Car_Information.txt",false);
        for(Car car:carSet){
            fw.write(car.toString()+"\n");
        }
        fw.flush();
        //释放资源
        fw.close();
    }
}
